package com.exigen.performance.test.webapp.dao;

import java.util.List;

import javax.persistence.Query;

import com.exigen.performance.test.webapp.domain.ScenarioEntity;
import com.exigen.performance.test.webapp.domain.base.GenericJPADAO;

/**
 * Class that collects scenario entity data from database
 * 
 * @author Maksim Savchuks
 * 
 */
public class ScenarioJpaDao extends GenericJPADAO<ScenarioEntity, Long>
		implements ScenarioDao {
	private final String query1 = "select distinct s from TestSummaryEntity t, ScenarioEntity s where t.projectId= :projectId and t.scenarioId = s.id";

	public ScenarioJpaDao() {
		super(ScenarioEntity.class);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.exigen.performance.test.webapp.dao.ScenarioDao#getScenarioByProject
	 * (java.lang.Long)
	 */
	public List<ScenarioEntity> getScenarioByProject(Long projectId) {
		Query query = getEntityManager().createQuery(query1);
		query.setParameter("projectId", projectId);
		@SuppressWarnings("unchecked")
		List<ScenarioEntity> result = query.getResultList();
		return result;
	}

}
